title = "分类详情页"
url = '/testtest/:slug|[a-z0-9\-]+-c-\d+.html$'
title = '分类详情页模板'
layout = 'default'
==
use Jason\Ccshop\Controllers\Filters;
use Jason\Ccshop\Controllers\Categories;
use Jason\Ccshop\Models\Category;
use Jason\Ccshop\Models\Product;

function onStart() {
$slugArr = explode('-', str_replace('.html', '', $this->param('slug')));

$id = array_pop($slugArr);
array_pop($slugArr);
$condition = ['id' => $id];
$this['paramKey'] = join('-', $slugArr);
$category = Categories::getCategory($condition);
if ($category) {

$pids = get('id_sort', null);
$pageNumber = get('page', 1);

if(!empty($pids)){
Cookie::queue('idssort',$pids);
Cookie::queue('cid',$id);
Cookie::queue('pagenumber',$pageNumber);
}else{
$pageNumber = Cookie::get('pagenumber');
$cid = Cookie::get('cid');
$currentPage = get('page', 1);
if($currentPage==$pageNumber && $id==$cid){
$pids = Cookie::get('idssort');
}
}

if (!empty($pids)) {
$pida = explode(',',$pids);
$pd = Product::InStock()->whereIn('id',$pida)->get();
$this['adproducts'] = $pd;
$this['pida'] = $pida;

}
dump($pida);
$this['category'] = $category;
if ($this['paramKey'] != $category['slug']) {
$orderArr = Filters::parseFilterKeyParams($this['paramKey']);
if (count($orderArr) == 2) {
$order = [$orderArr[0] => $orderArr[1]];
}
}
$this['order'] = isset($order) ? $order : ['saled' => 'desc'];
} else {
return redirect('/404');
}
//$this['products'] = App::make('Jason\Ccshop\Controllers\Products')->getCategoryProducts($category->id, $this['order']);
foreach($this['adproducts'] as $val){
    if($val->feature_image ){
        foreach($val->feature_image as $img){
            dump($img->path);
        }
    }
}
}
==

